package org.ex;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class Ex03 {
    public static void main(String[] args) {
        //生成随机日期（指定范围）
        //生成5个日期 2023-01-01 00:00:00 000 到现在的随机日期
        long start = LocalDateTime.of(2023, 1, 1, 0, 0, 0).toInstant(ZoneOffset.of("+08:00")).toEpochMilli();
        long ss = new Date("2023/1/1 0:0:0").getTime();
        System.out.println(start);
        System.out.println(ss);

        Calendar c = Calendar.getInstance();
        c.set(2023, 1 - 1, 1, 0, 0, 0);
        System.out.println(c.getTimeInMillis());
        System.out.printf("%tF %<tT %n", c);

        long end = System.currentTimeMillis();
        Random rand = new Random();
        for (int i = 0; i < 10; i++) {
            long time = rand.nextLong(start, end);
            System.out.printf("%tF %<tT %n", time);
        }
    }
}
